<template>
  <div class="goods-warn">
    <cl-form ref="Form" />
  </div>
</template>

<script lang="ts" name="goods-warn" setup>
import { useCool } from "/@/cool";
import { ElMessage, ElMessageBox } from "element-plus";
import { useCrud, useForm } from "@cool-vue/crud";
import dayjs from "dayjs";

const { service } = useCool();

// cl-form
const Form = useForm();

// cl-crud
const Crud = useCrud();

// 打开
async function open(ids: any[], tip: any[],cname:any) {
	Form.value?.open({
		title: "出险",
		width: "600px",
		props: {
			labelWidth: "120px",
			labelPosition: "top"
		},
		items: [
		{
			prop: "deptName",
			label: "公司名称",
			value:cname,
			span: 24,
			required: true,
			component: {
				name: "el-input"
			}
		},
		{
			prop: "goodsNo",
			label: "保单号码",
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		},
		{
			prop: "name",
			label: "出险人姓名",
			value:tip[0],
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		},
		{
			prop: "plusDate",
			label: "保险起期",
			required: true,
			span: 12,
			component: {
				name: "el-date-picker",
			}
		},
		{
			prop: "dangerDate",
			label: "出险时间",
			value: dayjs(),
			required: true,
			span: 12,
			component: {
				name: "el-date-picker",
			}
		},
		{
			prop: "directorName",
			label: "负责人姓名",
			value:tip[0],
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		}
		,
		{
			prop: "directorPhone",
			label: "负责人电话",
			value:tip[0],
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		}
		,
		{
			prop: "managerName",
			label: "公司联系人姓名",
			value:tip[0],
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		}
		,
		{
			prop: "managerPhone",
			label: "公司联系人电话",
			value:tip[0],
			required: true,
			span: 12,
			component: {
				name: "el-input"
			}
		}
		],
		on: {
			submit(data, { done, close }) {
				ElMessageBox.confirm("是否要提交？", "提示", {
					type: "warning"
				})
					.then(() => {
						service.demo.danger
							.add({
								...data
							})
					})

			}
		}
	});
}

defineExpose({
	open
});
</script>
